package com.gzy.cs5.service;

import com.gzy.cs5.Repository.InventoryRepository;
import com.gzy.cs5.exception.BusinessException;
import com.gzy.cs5.model.InventoryItem;

import java.util.List;

public class SimpleInventoryService implements InventoryService {
    private final InventoryRepository inventoryRepository;

    public SimpleInventoryService(InventoryRepository inventoryRepository) {
        this.inventoryRepository = inventoryRepository;
    }

    @Override
    public void addItem(InventoryItem item) throws BusinessException {
        inventoryRepository.addItem(item);
    }

    @Override
    public void removeItem(String itemId) throws BusinessException {
        inventoryRepository.removeItem(itemId);
    }

    @Override
    public List<InventoryItem> getAllItems() {
        return inventoryRepository.getAllItems();
    }

    @Override
    public InventoryItem getItemById(String itemId) {
        return inventoryRepository.getItemById(itemId);
    }

    @Override
    public void updateItemQuantity(String itemId, int quantity) throws BusinessException {
        inventoryRepository.updateItemQuantity(itemId, quantity);
    }
}